package com.teemor;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author zhoulike
 * @date 2024/7/9 14:33
 */
public class Channel {

    private Map<Integer, Node> nodes = new ConcurrentHashMap<>();



    public  void connect(Node node)
    {
        nodes.put(node.getId(), node);
    }


    public void sendMessage(Message message)
    {
        nodes.get(message.getReceiveId()).onMessage(message);
    }


    public Set<Integer> getNodes()
    {
        return nodes.keySet();
    }

}
